Skip to content

analytics: batch reports for install, reinstall and upgrade - #24561

Open
iMichka wants to merge 18 commits into
mainfrom
analytics
Open

iMichka wants to merge 18 commits into
mainfrom
analytics

Conversation

@iMichka

@iMichka iMichka commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

These commands report an event for every package they install,
including dependencies, dependants and casks, so a single run could
make dozens of separate requests to InfluxDB.

Add Utils::Analytics.batch_reports, which collects the events
reported in its block and sends them when the block finishes, as
newline-separated line protocol. Each request holds at most 100 lines
(INFLUX_MAX_BATCH_SIZE) to stay well under Linux's 128KiB limit on a
single curl argument.

brew.rb wraps these commands in a batch, so a run sends its
command_run event and every package event together. All other
commands still send each event immediately. That leaves commands that
exec (whose events would otherwise be lost) and long-running ones
like brew test-bot unchanged.

The batch is sent from an ensure rather than an at_exit handler,
so it is still sent on errors, exit and interrupts. Forked children
never send it.


  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include brew benchmark results.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; every commit has a human author or co-author and I will answer maintainer questions and review comments myself without AI/LLM.

I have used Claude Opus 5.5 for this

@iMichka

iMichka commented Nov 10, 2026

Copy link
Copy Markdown
Member Author

This is a quick implementation I tested. Batch size set to 10 is arbitrary

@SMillerDev

@iMichka

iMichka commented Nov 10, 2026

Copy link
Copy Markdown
Member Author

I won't be able to work on this tomorrow so please test / give feedback (and pick the PR up if you are faster than me to respond) :)

@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Summary

Summary by CodeRabbit

  • New Features

    • Install and upgrade analytics are batched, with nanosecond-precision timestamps to distinguish events.
    • Cask and formula activity is reported across installs, reinstalls, upgrades and related commands.
    • Formula reporting includes eligible dependencies and avoids duplicate package entries.
  • Bug Fixes

    • Analytics requests are split into size-limited batches; oversized events are sent separately.
    • Eligible install activity is reported before installation, and casks with failed downloads are excluded.
    • Analytics send failures no longer interrupt installation workflows.

This change adds batched Influx writes with nanosecond timestamps. It moves formula and cask install analytics reporting to shared workflow entry points. It also adds download verification support and updates tests for reporting, batching and analytics send failures.

Changes: Install analytics reporting

Layer / File(s) Summary
Build and send package event batches
Library/Homebrew/utils/analytics.rb, Library/Homebrew/test/utils/analytics_spec.rb, Library/Homebrew/test/install_spec.rb
Utils::Analytics formats Influx lines with nanosecond timestamps and distinct timestamps for reports within the same second. It batches lines into byte-limited requests and routes package reporting through report_package_events. deferred_curl logs send errors. Specs cover payloads, suppression, batching, and send failures.
Report formula installs
Library/Homebrew/utils/analytics.rb, Library/Homebrew/download_queue.rb, Library/Homebrew/formula_installer.rb, Library/Homebrew/install.rb, Library/Homebrew/upgrade.rb, Library/Homebrew/cmd/install.rb, Library/Homebrew/cmd/reinstall.rb, Library/Homebrew/cmd/upgrade.rb, Library/Homebrew/extend/os/mac/reinstall.rb, Library/Homebrew/cask/audit.rb, Library/Homebrew/cask/installer.rb, Library/Homebrew/test/utils/analytics_spec.rb, Library/Homebrew/test/download_queue_spec.rb, Library/Homebrew/test/formula_installer_spec.rb, Library/Homebrew/test/upgrade_spec.rb
Formula install analytics collect eligible installers and dependencies, then report from install, upgrade, reinstall, dependency, audit, and macOS reinstall workflows. FormulaInstaller adds dependency_installer, and DownloadQueue adds downloaded_and_verified?. Specs cover filtering, dependency setup, and reporting order.
Report cask installs
Library/Homebrew/utils/analytics.rb, Library/Homebrew/cask/installer.rb, Library/Homebrew/cask/reinstall.rb, Library/Homebrew/cask/upgrade.rb, Library/Homebrew/cmd/install.rb, Library/Homebrew/cmd/reinstall.rb, Library/Homebrew/cmd/upgrade.rb, Library/Homebrew/dev-cmd/cask-ci.rb, Library/Homebrew/test/utils/analytics_spec.rb, Library/Homebrew/test/cask/installer_spec.rb, Library/Homebrew/test/cask/upgrade_spec.rb
Cask install reporting filters failed downloads and ineligible taps. Install, reinstall, upgrade, dependency, and cask CI workflows report cask events. Upgrade workflows create fallback installers when needed. Specs cover cask filtering and upgrade reporting.
Merge Risk: Low · up to 2d722

This change batches analytics for install, reinstall and upgrade commands. The open concerns are minor reporting inaccuracies, opt-out edge cases and one typing signature. None is expected to break installs, but the owner should confirm them before merging.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "analytics: batch reports for install, reinstall and upgrade" matches the main change. The changeset adds batched analytics reporting through report_package_events and related helpers, and…
Description check Passed The description explains the purpose (reducing InfluxDB requests from install-related commands), the new batching mechanism, the 100-line cap, which commands are affected, and the send-from-ensure beh…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "analytics: batch reports for install, reinstall and upgrade" matches the main change. The changeset adds batched analytics reporting through report_package_events and related helpers, and wires them into install, reinstall and upgrade paths. The title is specific and concise.

Full details: Description check

Explanation

The description explains the purpose (reducing InfluxDB requests from install-related commands), the new batching mechanism, the 100-line cap, which commands are affected, and the send-from-ensure behaviour. These match the changeset. The description also includes a conflicting statement: it says each request holds at most 100 lines, while the raw summary says batches are capped at 65,536 bytes with INFLUX_MAX_BATCH_BYTES. It also names Utils::Analytics.batch_reports and brew.rb, which the raw summary does not list. The description is related to the changeset, so the check passes, but the mismatch is worth noting.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7bfb937e-c135-4173-8ff0-ac34f91c9a60
Commits

Reviewing files that changed from the base of the PR and between 95d4938 and 8cd1d38.

Files selected for processing: 1

  • Library/Homebrew/utils/analytics.rb

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread Library/Homebrew/utils/analytics.rb Resolved
@iMichka

iMichka commented Nov 11, 2026 •

Copy link
Copy Markdown
Member Author

BTW some more information about this idea:

In InfluxDB line protocol each line is one point, and the format defines \n as the separator between points.

  • /api/v2/write, the endpoint brew posts to, is built for batches: InfluxDB recommends sending up to about 5,000 lines per request. A batch > of 10 is well within that.
  • InfluxDB 3 accepts the same /api/v2/write request, so this holds even if the server moves to v3.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cf4476a1-8228-4e65-b3b6-a6160c388e1d
Commits

Reviewing files that changed from the base of the PR and between 8cd1d38 and 504ca3e.

Files selected for processing: 4

  • Library/Homebrew/env_config.rb
  • Library/Homebrew/sorbet/rbi/dsl/homebrew/env_config.rbi
  • Library/Homebrew/test/utils/analytics_spec.rb
  • Library/Homebrew/utils/analytics.rb

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread Library/Homebrew/utils/analytics.rb Resolved
Comment thread Library/Homebrew/utils/analytics.rb Resolved

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, good idea, few thoughts.

Comment thread Library/Homebrew/env_config.rb Resolved
Comment thread Library/Homebrew/utils/analytics.rb Resolved
Comment thread Library/Homebrew/utils/analytics.rb Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick comments: 1

Library/Homebrew/test/utils/analytics_spec.rb: 1

151-151: Trivial · Maintainability & Code Quality · Quick win

Test the automatic batch boundary.

Add a test that checks no request is sent for nine events and that the tenth sends one request containing all ten newline-separated records.

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d75cd06e-d687-4c32-a76a-260e768fc691
Commits

Reviewing files that changed from the base of the PR and between 0bcf90c and 2bc134f.

Files selected for processing: 2

  • Library/Homebrew/test/utils/analytics_spec.rb
  • Library/Homebrew/utils/analytics.rb

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@iMichka iMichka changed the title analytics: batch api calls analytics: batch reports for install, reinstall and upgrade Nov 12, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f8820d94-a606-4a22-a709-24e3b82680a8
Commits

Reviewing files that changed from the base of the PR and between 2bc134f and 4cce05e.

Files selected for processing: 3

  • Library/Homebrew/brew.rb
  • Library/Homebrew/test/utils/analytics_spec.rb
  • Library/Homebrew/utils/analytics.rb

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread Library/Homebrew/utils/analytics.rb Resolved
@iMichka

iMichka commented Nov 12, 2026

Copy link
Copy Markdown
Member Author

@MikeMcQuaid I changed the implementation completely, based on your feedback. Let me know if this goes in the right direction.

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looking better!

Comment thread Library/Homebrew/utils/analytics.rb Resolved
Comment thread Library/Homebrew/utils/analytics.rb Resolved
Comment thread Library/Homebrew/utils/analytics.rb Resolved
Comment thread Library/Homebrew/brew.rb Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Major · Keep analytics launch failures outside the installation result. · analytics.rb:85

Library/Homebrew/utils/analytics.rb:85
Major · Stability & Availability · Quick win

Keep analytics launch failures outside the installation result.

If the final curl launch fails, spawn raises rather than returning a failure value. Ruby 4.0 documents this behaviour. (docs.ruby-lang.org)

This flush now runs after the changed loops’ per-item rescues. Its exception therefore aborts subsequent installation work and finalisation. During formula reinstall, it can also replace an escaping BuildError before the global handler receives it.

Handle analytics transport failures at the flush boundary. Preserve the block’s return value or original exception. Add regression coverage for both cases.

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e3039b61-ef3e-4913-8b74-d4e89134bb47
Commits

Reviewing files that changed from the base of the PR and between 4cce05e and 348e61b.

Files selected for processing: 9

  • Library/Homebrew/cask/reinstall.rb
  • Library/Homebrew/cask/upgrade.rb
  • Library/Homebrew/cmd/install.rb
  • Library/Homebrew/cmd/reinstall.rb
  • Library/Homebrew/install.rb
  • Library/Homebrew/test/install_spec.rb
  • Library/Homebrew/test/utils/analytics_spec.rb
  • Library/Homebrew/upgrade.rb
  • Library/Homebrew/utils/analytics.rb

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread Library/Homebrew/cask/reinstall.rb Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cfc31217-48ad-4d99-9781-fedaae115503
Commits

Reviewing files that changed from the base of the PR and between 348e61b and e43a2e4.

Files selected for processing: 14

  • Library/Homebrew/cask/audit.rb
  • Library/Homebrew/cask/installer.rb
  • Library/Homebrew/cask/reinstall.rb
  • Library/Homebrew/cmd/install.rb
  • Library/Homebrew/cmd/reinstall.rb
  • Library/Homebrew/dev-cmd/cask-ci.rb
  • Library/Homebrew/extend/os/mac/reinstall.rb
  • Library/Homebrew/formula_installer.rb
  • Library/Homebrew/install.rb
  • Library/Homebrew/test/formula_installer_spec.rb
  • Library/Homebrew/test/install_spec.rb
  • Library/Homebrew/test/utils/analytics_spec.rb
  • Library/Homebrew/upgrade.rb
  • Library/Homebrew/utils/analytics.rb

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread Library/Homebrew/cask/installer.rb Resolved
Comment thread Library/Homebrew/cmd/install.rb Resolved
Comment thread Library/Homebrew/utils/analytics.rb Resolved

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeh, thanks @iMichka, this is much more the approach I had in mind!

Comment thread Library/Homebrew/cask/installer.rb Resolved
Comment thread Library/Homebrew/cmd/install.rb Resolved
Comment thread Library/Homebrew/formula_installer.rb Resolved
@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Checking this code-generation request.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Nitpick comments: 2

Library/Homebrew/test/utils/analytics_spec.rb: 1

188-191: Trivial · Maintainability & Code Quality · Quick win

Keep one analytics spec that uses the real dependency installer.

The previous integration example fed a real FormulaInstaller into event construction. The replacement supplies a dependency installer double with the expected status and options already set. It checks how analytics reads those values, but not whether dependency_installer derives them from the dependency and its keg receipt. Keep the isolated examples and add one case that captures report_package_events while using the real helper. (github.com)

Library/Homebrew/test/formula_installer_spec.rb: 1

903-908: Trivial · Maintainability & Code Quality · Quick win

Cover the request flag from an installed dependency’s tab.

This example would still pass if dependency_installer always returned an installer with installed_on_request: false. Add an example with an installed dependency whose tab has installed_on_request: true and a parent installer whose flag is false. Expect the returned installer’s flag to be true. Together, the examples distinguish preserving the tab’s flag from copying the parent’s flag or always returning false.

Additional comments: 1

Library/Homebrew/utils/analytics.rb: 1

192-192: Minor · Data Integrity & Integration · Quick win

Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Report cask dependencies with on_request: false.

When a requested cask pulls in a missing cask dependency, the dependency installer records installed_on_request: false. The analytics caller passes only the cask, so Line 192 emits on_request: true. This counts the dependency as explicitly requested, contrary to the documented meaning of the tag. Pass the installer status with each cask. Keep true for explicitly requested installs. (raw.githubusercontent.com)

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 42455b54-f243-482d-9abc-8d035085791b
Commits

Reviewing files that changed from the base of the PR and between e43a2e4 and d921c77.

Files selected for processing: 4

  • Library/Homebrew/formula_installer.rb
  • Library/Homebrew/test/formula_installer_spec.rb
  • Library/Homebrew/test/utils/analytics_spec.rb
  • Library/Homebrew/utils/analytics.rb
Files with no reviewable changes: 1

  • Library/Homebrew/formula_installer.rb

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread Library/Homebrew/utils/analytics.rb Resolved
@HaraldNordgren

Copy link
Copy Markdown
Member

Interesting idea for sure!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 304d74ce-305b-4b60-9d00-1db9772436e9
Commits

Reviewing files that changed from the base of the PR and between d921c77 and 9f45d7c.

Files selected for processing: 15

  • Library/Homebrew/cask/audit.rb
  • Library/Homebrew/cask/installer.rb
  • Library/Homebrew/cask/reinstall.rb
  • Library/Homebrew/cask/upgrade.rb
  • Library/Homebrew/cmd/install.rb
  • Library/Homebrew/cmd/reinstall.rb
  • Library/Homebrew/dev-cmd/cask-ci.rb
  • Library/Homebrew/install.rb
  • Library/Homebrew/sorbet/rbi/dsl/rubo_cop/cop/homebrew/no_untyped_keyword_rest.rbi
  • Library/Homebrew/test/cask/upgrade_spec.rb
  • Library/Homebrew/test/formula_installer_spec.rb
  • Library/Homebrew/test/install_spec.rb
  • Library/Homebrew/test/utils/analytics_spec.rb
  • Library/Homebrew/upgrade.rb
  • Library/Homebrew/utils/analytics.rb

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread Library/Homebrew/cask/installer.rb Resolved
Comment thread Library/Homebrew/cask/upgrade.rb Resolved
@iMichka

iMichka commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Latests change brought a lot of new code rabbit comments, I will go through them and try to solve them.

Reports are now sent after the downloads, and before the install, for both cask and formula

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 30f88b60-c5e7-424b-bb16-cf35cf2d0737
Commits

Reviewing files that changed from the base of the PR and between fca4188 and a9e6083.

Files selected for processing: 2

  • Library/Homebrew/cask/upgrade.rb
  • Library/Homebrew/test/cask/upgrade_spec.rb

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

Comment thread Library/Homebrew/cask/upgrade.rb Resolved
These commands report an event for every package they install,
including dependencies, dependants and casks, so a single run could
make dozens of separate requests to InfluxDB.

Add `Utils::Analytics.batch_reports`, which collects the events
reported in its block and sends them when the block finishes, as
newline-separated line protocol. Each request holds at most 100 lines
(`INFLUX_MAX_BATCH_SIZE`) to stay well under Linux's 128KiB limit on a
single `curl` argument.

`brew.rb` wraps these commands in a batch, so a run sends its
`command_run` event and every package event together. All other
commands still send each event immediately. That leaves commands that
`exec` (whose events would otherwise be lost) and long-running ones
like `brew test-bot` unchanged.

The batch is sent from an `ensure` rather than an `at_exit` handler,
so it is still sent on errors, `exit` and interrupts. Forked children
never send it.
Instead of batching analytics until a block finishes, have each loop
that installs formulae or casks send a single request for everything
it is about to install, dependencies included, before installing
anything.

Move the reports out of `FormulaInstaller#install` and
`Cask::Installer#install` into the loops that call them using the new
`Utils::Analytics.report_formula_installs` and `report_cask_installs`.
Remove `batch_reports` and the command list in `brew.rb`.
…ing queued is now downloaded with upgrade_cask's fallback installer before the report and included in it
…talls or replaces a BuildError: deferred_curl

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7132850b-7488-475b-ae26-b6b24c543b88
Commits

Reviewing files that changed from the base of the PR and between a9e6083 and 9520090.

Files selected for processing: 12

  • Library/Homebrew/cask/audit.rb
  • Library/Homebrew/cask/installer.rb
  • Library/Homebrew/cmd/install.rb
  • Library/Homebrew/cmd/reinstall.rb
  • Library/Homebrew/formula_installer.rb
  • Library/Homebrew/install.rb
  • Library/Homebrew/test/cask/upgrade_spec.rb
  • Library/Homebrew/test/formula_installer_spec.rb
  • Library/Homebrew/test/install_spec.rb
  • Library/Homebrew/test/utils/analytics_spec.rb
  • Library/Homebrew/upgrade.rb
  • Library/Homebrew/utils/analytics.rb

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread Library/Homebrew/formula_installer.rb Resolved
Comment thread Library/Homebrew/utils/analytics.rb Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6b782e74-0ff5-4f24-8723-1f48041fa99f
Commits

Reviewing files that changed from the base of the PR and between be1ad9b and cfa0e2b.

Files selected for processing: 11

  • Library/Homebrew/cask/installer.rb
  • Library/Homebrew/cask/reinstall.rb
  • Library/Homebrew/cask/upgrade.rb
  • Library/Homebrew/cmd/install.rb
  • Library/Homebrew/cmd/reinstall.rb
  • Library/Homebrew/cmd/upgrade.rb
  • Library/Homebrew/install.rb
  • Library/Homebrew/test/cask/installer_spec.rb
  • Library/Homebrew/test/install_spec.rb
  • Library/Homebrew/test/upgrade_spec.rb
  • Library/Homebrew/upgrade.rb
Files with no reviewable changes: 1

  • Library/Homebrew/install.rb

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread Library/Homebrew/cask/upgrade.rb Resolved
- `report_formula_installs` read the `compute_dependencies` list
  cached while fetching, which can include dependencies another
  formula has installed since, so they could be reported twice.
- Use `use_cache: false` as `FormulaInstaller#install` does, so
  the report matches the dependencies that install processes.
- Fallback installers run their prelude, including
  `check_conflicts`, before any upgrade so their downloads can be
  reported together. An earlier upgrade can then install a cask
  that conflicts with a later one.
- Re-run `check_conflicts` on fallback installers right before
  their upgrade so that conflict still stops it.
- A fallback whose early download fails is skipped in the batch
  report, and `upgrade_cask` then retries the download when it
  stages the cask, so a successful retry was never reported.
- Report a fallback that `upgrade_cask` builds itself once staging
  has downloaded and verified it, keeping one report per cask.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bf705a7c-5e3d-4642-b4f2-142626717c88
Commits

Reviewing files that changed from the base of the PR and between a00b43a and 920c957.

Files selected for processing: 2

  • Library/Homebrew/cask/upgrade.rb
  • Library/Homebrew/test/cask/upgrade_spec.rb

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

Comment thread Library/Homebrew/cask/upgrade.rb Resolved
- Each `report_package_events` call restarted its nanosecond offset
  at zero, so two reports in the same second, such as a batch and a
  fallback retry, could send identical points that InfluxDB merges.
- Allocate timestamps in `influx_line` from the current second or
  one nanosecond after the last one used, kept in the `Cacheable`
  cache so every report in the process shares it.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Minor · Preserve explicit installer metadata when removing duplicates. · analytics.rb:198

Library/Homebrew/utils/analytics.rb:198
Minor · Data Integrity & Integration · Quick win

Preserve explicit installer metadata when removing duplicates.

If both foo and its dependency bar are explicitly requested, collection can produce bar/on_request=false before the explicit bar/on_request=true record. uniq retains the dependency record and discards the explicit record. The install command reports these installers together before installation. (raw.githubusercontent.com)

Prefer the included top-level installer's metadata when a package also appears as a dependency. Keep one event per package. Preserve dependency metadata when no included top-level installer exists. Add a regression case with the dependent installer first. The current selector makes request status, and potentially options, depend on input order. (raw.githubusercontent.com)

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 719eaaf1-2d16-405d-8352-6e9782e40431
Commits

Reviewing files that changed from the base of the PR and between 920c957 and 7f476a9.

Files selected for processing: 5

  • Library/Homebrew/test/cask/upgrade_spec.rb
  • Library/Homebrew/test/formula_installer_spec.rb
  • Library/Homebrew/test/upgrade_spec.rb
  • Library/Homebrew/test/utils/analytics_spec.rb
  • Library/Homebrew/utils/analytics.rb
Files with no reviewable changes: 3

  • Library/Homebrew/test/cask/upgrade_spec.rb
  • Library/Homebrew/test/formula_installer_spec.rb
  • Library/Homebrew/test/upgrade_spec.rb

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

- With `HOMEBREW_DOWNLOAD_CONCURRENCY=1`, `install_fetch_deps`
  installs implicit dependencies such as `xz` during `prelude`,
  before the batch report, which then no longer includes them.
- Report each such dependency once `DownloadQueue` has verified
  its download and before installing it. Ordinary dependencies
  stay in the batch report so nothing is counted twice.
- Add `DownloadQueue#downloaded_and_verified?` to wait for a
  single queued download without printing its failure twice.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ab2134d0-b21e-4590-adba-c408eb1e67f7
Commits

Reviewing files that changed from the base of the PR and between 7f476a9 and 2d722f1.

Files selected for processing: 4

  • Library/Homebrew/download_queue.rb
  • Library/Homebrew/formula_installer.rb
  • Library/Homebrew/test/download_queue_spec.rb
  • Library/Homebrew/test/formula_installer_spec.rb

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

download = @downloads_by_location[downloadable.cached_download]
return downloadable.downloaded_and_valid? if download.nil?

download.wait.fulfilled?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Data Integrity & Integration · Quick win

Require content verification before returning true.

For a corrupt cached immutable bottle, Bottle#downloaded_and_valid? can return true because its filename matches the expected digest. enqueue then fulfils this raw future at Line 71 without checking the contents. This method returns true and permits install_fetch_deps to report the unverified dependency.

Use a content-verification result before returning true. Preserve the silent false result for rejected downloads.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants